const router = require('koa-router')()
const GoodsModel = require('../models/goods');

router.get('/goods/list', async (ctx) => {
  var data = await GoodsModel.find({});
  ctx.body = {
    code:200,
    msg:"请求成功",
    total:data.length,
    result:data
  }
});
router.get('/goods/price',async ctx=>{
  var {gt,lt} = ctx.query;
  var data = await GoodsModel.find({salePrice:{$gt:gt,$lt:lt}});
  ctx.body = {
    code:200,
    msg:"请求成功",
    total:data.length,
    result:data
  }
})



module.exports = router
